package com.jtbd.service.impl.campus;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jtbd.domain.Customers;
import com.jtbd.handler.GetSecurityUserHandler;
import com.jtbd.mapper.CustomersMapper;
import com.jtbd.service.campus.CustomersService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class CustomersServiceImpl extends ServiceImpl<CustomersMapper, Customers> implements CustomersService {
    @Resource
    private CustomersMapper customersMapper;

    /**
     * 添加客户信息
     *
     * @param customers 客户对象，包含客户的基本信息
     * @return 返回添加成功的客户ID，添加失败则返回null
     */
    public Long addCustomer(Customers customers) {
        Long userId = GetSecurityUserHandler.getSecurityUserId();
        customers.setCreateId(userId);
        customers.setUpdateId(userId);
        // 执行客户信息插入操作
        int result = customersMapper.insert(customers);
        if (result > 0) {
            return customers.getId();
        }
        return null;
    }

}
